package com.cff.pm.handler;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cff.pm.client.HttpSpider;
import com.cff.pm.client.OkHttpSpider;
import com.cff.pm.util.DateUtil;

public class HandlerFactory {
	public static String HTTP_TYPE = "OKHTTP";

	public static LoginHandler getLoginHandler() {
		if (HTTP_TYPE.equals("OKHTTP")) {
			HttpSpider spider = new OkHttpSpider();
			LoginHandler loginHandler = new LoginHandler();
			loginHandler.setHttpSpider(spider);
			return loginHandler;
		}

		return null;
	}

	public static LogHandler getLogHandler(LoginHandler loginHandler) {
		LogHandler logHandler = new LogHandler();
		logHandler.setLoginHandler(loginHandler);
		return logHandler;
	}

	public static LogHandler getLogHandler() {
		LogHandler logHandler = new LogHandler();
		return logHandler;
	}

	public static WeixinMessageHandler getWeixinMessageHandler(String businessId, String salt, String url,
			List<String> recipients) {
		WeixinMessageHandler weixinMessageHandler = new WeixinMessageHandler(businessId, salt, url, recipients);
		return weixinMessageHandler;
	}

	public static WeixinMessageHandler getWeixinMessageHandler(String businessId, String salt, String url, String recipients) {
		List<String> recipientList = new ArrayList<>();
		recipientList.add(recipients);
		WeixinMessageHandler weixinMessageHandler = new WeixinMessageHandler(businessId, salt, url, recipientList);
		return weixinMessageHandler;
	}
	
	public static HolidayHandler getHolidayHandler(String date) {
		HolidayHandler holidayHandler = new HolidayHandler(date);
		return holidayHandler;
	}
	public static HolidayHandler getHolidayHandler() {
		String date = DateUtil.format(new Date(), DateUtil.SimpleDatePattern);
		HolidayHandler holidayHandler = new HolidayHandler(date);
		return holidayHandler;
	}
	
}
